package com.kabuda.zhugehot200_review;

/**
 * @author kabuda
 * @date 2025-03-15 15:49
 * @description
 */
public class t26_删除排序数组重复项 {
    public static void main(String[] args) {
        System.out.println(removeDuplicates(new int[]{0, 0, 1, 1, 1, 2, 2, 3, 3, 4}));
    }

    /**
     * 快慢指针
     *
     * @param nums
     * @return
     */
    public static int removeDuplicates(int[] nums) {
        int fast = 0;
        int slow = 0;
        while (++fast < nums.length) {
            if (nums[fast] != nums[slow]) {
                nums[++slow] = nums[fast];
            }
        }
        return slow+1;
    }
}
